<!-- 地震影响场 -->
<template>
  <el-dialog v-model="open" title="选择影响场数据" @open="initOpen" @close="close">
    <p></p>
    <el-table :data="tableList" v-loading="loading" @row-click="rowClick">
      <el-table-column label="选择" width="55" align="center">
        <template #default="{ row }">
          <el-radio-group v-model="selectedId">
            <el-radio :label="row.versionCode">{{ '' }}</el-radio>
          </el-radio-group>
        </template>
      </el-table-column>
      <el-table-column type="index" label="序号" width="55" align="center" />
      <el-table-column label="版本号" prop="versionCode" align="center" />
      <el-table-column label="长短轴方向" prop="direction" align="center" />
      <el-table-column label="地震烈度" prop="earthquakeLevel" align="center" />
    </el-table>
    <pagination style="margin-top: 15px" v-show="queryParams.total > 0" :total="queryParams.total"
          v-model:page="queryParams.page" v-model:limit="queryParams.rows" @pagination="getList" />
    <template #footer>
      <el-button type="primary" @click="confirm" auto-insert-space>确定</el-button>
      <el-button plain @click="close" auto-insert-space>取消</el-button>
    </template>
  </el-dialog>
</template>
<script setup>
import { getSeismicInfluence } from '@/api/building'

const props = defineProps({
  open: Boolean,
  selected: String
})
const emits = defineEmits(['update:open', 'getInfluence'])
const route = useRoute()

const tableList = ref([])
const loading = ref(false)
const selectedId = ref('')
// 查看
const queryParams = ref({
  page: 1,
  rows: 10,
  total: 0
})

const getList = () => {
  loading.value = true;
  const { page, rows } = queryParams.value
  getSeismicInfluence({page: page,rows: rows}).then(res => {
    tableList.value = res.data.rows || []
    queryParams.value.total = res.data.total
    loading.value = false
  })
}

const initOpen = () => {
  getList()
  selectedId.value = props.selected
}
const rowClick = (row) => {
  selectedId.value = row.fsiId
}
const close = () => {
  emits('update:open', false)
}
const confirm = () => {
  emits('getInfluence', selectedId.value)
  close()
}
</script>
<style scoped></style>